import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import legacy from "@vitejs/plugin-legacy";
import path from "path";
import postCssPxToRem from "postcss-pxtorem";


// https://vite.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    vue(),
    legacy({
      targets: ["defaults", "not IE 11"],
    }),
  ],
  resolve: {
    // ↓路径别名
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 192, // 按照自己的设计稿修改 1920/10
          unitPrecision: 5, // 保留到5位小数
          selectorBlackList: ["ignore"], // 忽略转换正则匹配项
          propList: ["*", "!border"],
          replace: true,
          mediaQuery: false, // 媒体查询( @media screen 之类的)中不生效
          minPixelValue: 1, //可以选择px小于1的不会被转换
        }),
      ],
    },
  },
});
